public class Test4 {
    public static void main(String[] args) {
        for(int i=0;i<999;i++){
            int count=0;
            int temp=i;
            while(temp!=0){
                count++;
                temp=temp/10;
            }
            temp=i;
            int sum=0;
            while(temp!=0){
                sum+=Math.pow(temp%10,count);
                temp=temp/10;
            }
            if(sum==i){
                System.out.print(i+" ");
            }
        }
    }
}
